package com.mayavi.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;

import com.mayavi.bo.MovieTagBo;
import com.mayavi.dao.IMovieTagDao;

public class MovieTagDaoImpl implements IMovieTagDao {

	private HibernateTemplate hibernateTemplate;
	
	public void setSessionFactory(SessionFactory sessionFactory){
		this.hibernateTemplate = new HibernateTemplate(sessionFactory);
	}
	
	@Override
	public List<MovieTagBo> getAllTags() {
		return hibernateTemplate.find("from MovieTagBo");
	}

	@Override
	public MovieTagBo getTagById(Integer id) {
		return (MovieTagBo)hibernateTemplate.get(MovieTagBo.class, id);
	}

	@Override
	public void saveTag(MovieTagBo tagBo) {
		hibernateTemplate.saveOrUpdate(tagBo);
	}

}
